/*
2022-3-13
https://leetcode-cn.com/problems/maximize-the-topmost-element-after-k-moves/
*/
class Solution {
public:
    int maximumTop(vector<int>& nums, int k) {
        int len=nums.size();
        if(len==1 && k&1) return -1;
        if(len==1) return nums[0];
        int ans=-1e9;
        for(int i=0;i<=min(k,len-1);i++)
        {
            if(i!=k-1) ans=max(ans,nums[i]);
        }
        return ans;
    }
};
